﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace ProgramMain.OpticNet
{
    public partial class FrmCableBoxes  : ProgramMain.Framework.frmBase
    {
        public FrmCableBoxes()
        {
            InitializeComponent();

            UniqueIdent = GenerateFormIdent();
        }

        private static string GenerateFormIdent()
        {
            return GenerateUniqueIdent(MethodInfo.GetCurrentMethod().DeclaringType.Name);
        }

        public static FrmCableBoxes ShowForm()
        {
            return FrmCableBoxes.ShowForm(true);
        }

        public static FrmCableBoxes ShowForm(bool Refresh)
        {
            string FormIdent = GenerateFormIdent();
            FrmCableBoxes frm = (FrmCableBoxes)FindForm(FormIdent);
            if (frm != null)
            {
                frm.Activate();
            }
            else
            {
                frm = new FrmCableBoxes();
                frm.ShowAsMDI(Program.MainForm);
            }
            if (Refresh)
                frm.RefreshForm();

            return frm;
        }

        public void RefreshForm()
        {
            cableBoxList1.RefreshControl();
        }

        public void SetActiveCableBox(int? cableBoxID)
        {
            panelShowAll.Visible = true;
            layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            cableBoxList1.DetailID = cableBoxID;
            panelShowAll.Visible = true;
            RefreshForm();
        }

        private void cableBoxList1_ViewRowIDChanged(object sender, Framework.BaseDetailCtl.ShowDetailEventArgs e)
        {
            fibreList1.DetailID = e.DetailID;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            panelShowAll.Visible = false;
            layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            cableBoxList1.DetailID = null;
            RefreshForm();
        }
    }
}
